package com.jiwei.system.controller;


import com.jiwei.system.pojo.MemberLogin;
import com.jiwei.system.utils.CookieUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RequestMapping(value = "admin")
@Controller
public class AdminPageController {

    @GetMapping("index")
    public ModelAndView IndexPage(){
        return new ModelAndView("pages/Admin/index/index");
    }
    /**
     * 用户个人信息页
     * @return ModelAmdView对象，对应templates的实体html
     */
    @GetMapping("personalInfoPage")
    public ModelAndView personalInformationPage(){
        return new ModelAndView("pages/Admin/personalCenter/myInfo");
    }

    /**
     * 用户查看个人任务页
     * @return ModelAmdView对象，对应templates的实体html
     */
    @GetMapping("myTaskList")
    public ModelAndView memberTaskListPage(){
        return new ModelAndView("pages/Admin/personalCenter/myWork");
    }

    /**
     * 用户修改密码页
     * @return ModelAmdView对象，对应templates的实体html
     */
    @GetMapping("changePassword")
    public ModelAndView changePasswordPage(){
        return new ModelAndView("pages/Admin/personalCenter/changePassword");
    }

    @GetMapping("getWaitingReturnList")
    public ModelAndView returnThingPage(){
        return new ModelAndView("pages/Admin/personalCenter/unreturnedItems");
    }

    @GetMapping("getCanBorrowItemList")
    public ModelAndView canBorrowItemPage(){
        return new ModelAndView("pages/Admin/materials/materialsBorrowing");
    }

    @GetMapping("getCanBorrowBook")
    public ModelAndView canBorrowBookPage(){
        return new ModelAndView("pages/Admin/materials/booksBorrowing");
    }


    @GetMapping("quit")
    public String quit(HttpServletResponse response, HttpServletRequest request){
//        CookieUtil.removeMemberCookie(response,"author_token");
//        CookieUtil.removeMemberCookie(response,"role_token");
        request.getSession().removeAttribute("login");
        MemberLogin memberLogin = (MemberLogin) request.getSession().getAttribute("login");
        System.out.print("退出后的session为：");
        System.out.println(memberLogin);
        return "redirect:/member/login";
    }
    /**
     * 成员列表
     * @return  ModelAmdView对象，对应templates的实体html
     */
    @GetMapping(value = "memberList")
    public ModelAndView memberListPage(){
        return new ModelAndView("pages/Admin/member/memberList");
    }

    /**
     * 接线员列表
     * @return  ModelAmdView对象，对应templates的实体html
     */
    @GetMapping(value = "operatorList")
    public ModelAndView operatorListPage(){
        return new ModelAndView("pages/Admin/member/operatorList");
    }

    /**
     * 所有任务列表页
     * @return  ModelAmdView对象，对应templates的实体html
     */
    @GetMapping(value = "memberAllTaskList")
    public ModelAndView Page(){
        return new ModelAndView("pages/Admin/taskCenter/allTask");
    }

    @GetMapping("getItemHistory")
    public ModelAndView thingListPage(){
        return new ModelAndView("pages/Admin/materials/materialsBorrowHistory");
    }

    @GetMapping("getBookHistory")
    public ModelAndView borrowListPage(){
        return new ModelAndView("pages/Admin/materials/booksBorrowHistory");
    }

    @GetMapping("getAllThingList")
    public ModelAndView addItemPage(){
        return new ModelAndView("pages/Admin/materials/materialsList");
    }

    /**
     * 未完成任务的页面
     * @return ModelAmdView对象，对应templates的实体html
     */
    @GetMapping(value = "onlineTaskList")
    public ModelAndView DoingListPage() {
        return new ModelAndView("pages/Admin/taskCenter/toBeDone");
    }

    /**
     * 线下任务的页面
     * @return ModelAmdView对象，对应templates的实体html
     */
    @GetMapping(value = "offlineTaskList")
    public ModelAndView OfflineListPage() {
        return new ModelAndView("pages/Admin/taskCenter/offlineTask");
    }


    /**
     * 未接取的任务的页面
     * @return ModelAmdView对象，对应templates的实体html
     */
    @GetMapping(value = "waitingTaskList")
    public ModelAndView WaitingListPage() {
        return new ModelAndView("pages/Admin/taskCenter/toBeReleased");
    }
}
